﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using _6.jkxt;

namespace ServoTrack.WinForm
{
    public partial class interfaceForm : Form
    {
        public interfaceForm()
        {
            InitializeComponent();
        }

        private void interfaceForm_Load(object sender, EventArgs e)
        {
            dZ1.Text = Main.csName.pl[49, 1];
            dZ2.Text = Main.csName.pl[50, 1];
            dZ3.Text = Main.csName.pl[51, 1];
            dZ4.Text = Main.csName.pl[52, 1];
        }

        private void interfaceForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                string strFilePath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, Environment.CurrentDirectory + "\\text\\deploy.ini");
                if (File.Exists(strFilePath))
                {
                    string strContent = File.ReadAllText(strFilePath);
                    strContent = Regex.Replace(strContent, "方位俯仰电机接口:" + Main.csName.pl[49, 1] +
                        "\r\n极化电机接口:" + Main.csName.pl[50, 1] +
                        "\r\n编码器接口:" + Main.csName.pl[51, 1] +
                        "\r\n信标机接口:" + Main.csName.pl[52, 1],
                        "方位俯仰电机接口:" + dZ1.Text +
                        "\r\n极化电机接口:" + dZ2.Text +
                        "\r\n俯编码器接口:" + dZ3.Text +
                        "\r\n信标机接口:" + dZ4.Text);
                    File.WriteAllText(strFilePath, strContent);
                    Main.csName.pl[49, 1] = dZ1.Text;
                    Main.csName.pl[50, 1] = dZ2.Text;
                    Main.csName.pl[51, 1] = dZ3.Text;
                    Main.csName.pl[52, 1] = dZ4.Text;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
        }
    }
}
